{extend name="common:base" /}

{block name="main"}
<div class="admin-content-body">
    <div class="am-cf am-padding">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">首页</strong> / <small>一些常用模块</small></div>
    </div>
    <ul class="am-avg-sm-1 am-avg-md-4 am-margin am-padding am-text-center admin-content-list ">
        <li><a href="javascript:void()" onclick="expand('ss')" class="am-text-success">
            <span class="am-icon-btn am-icon-cart-plus"></span><br/>本周新增商品<br/>{$new_goods}</a></li>
        <li><a href="{:url('admin/goods/list', ['filter'=>1])}" class="am-text-danger">
            <span class="am-icon-btn am-icon-cart-arrow-down"></span><br/>正在出售<br/>{$in_sale}</a></li>
        <li><a href="{:url('admin/goods/list', ['filter'=>2])}" class="am-text-warning">
            <span class="am-icon-btn am-icon-bar-chart"></span><br/>总成交<br/>{$saled}</a></li>
        <li><a href="{:url('admin/users/list')}" class="am-text-secondary">
            <span class="am-icon-btn am-icon-user-md"></span><br/>总用户<br/>{$user_count}</a></li>
    </ul>
    <div class="am-g">
        <div class="am-u-sm-12">
            <div class="am-panel am-panel-default">
            <div class="am-panel-hd am-cf" onclick="expand('ss')">快速审核二手货<span class="am-icon-chevron-down am-fr"></span></div>
                <div class="am-panel-bd am-collapse am-in am-cf" id="childss" style="display: none">
                    <table class="am-table am-table-striped am-table-hover table-main">
                        <thead>
                            <tr>
                                <th class="table-id">ID</th>
                                <th class="table-title">商品名</th>
                                <th class="table-type">商品类型</th>
                                <th class="table-author">用户名</th>
                                <th class="table-status">商品当前状态</th>
                                <th class="table-set">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                    <tbody>
                        {volist name="list" id="voo"}
                        <tr>
                            <td>{$voo.good_id}</td>
                            <td><a href="{:url('goods/detail',['good_id'=>$voo.good_id])}">{$voo.title}</a></td>
                            <td>{$voo.cate_id|get_goodtype}</td>
                            <td>{$voo.user_id|get_username}</td>
                            <td>{$voo.status}</td>
                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        {if ($voo.status == "待审核" || $voo.status == "审核未通过")}
                                            <button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="ajax_through({$voo.good_id})" type="button"><span class="am-icon-pencil-square-o"></span>
                                            通过审核
                                            </button>
                                        {else/}
                                            <button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="ajax_through({$voo.good_id})" disabled type="button"><span class="am-icon-pencil-square-o"></span>
                                            无法操作
                                            </button>
                                        {/if}

                                        {if ($voo.status == "待审核" || $voo.status == "在售")}
                                            <button class="am-btn am-btn-default am-btn-xs am-hide-sm-only" onclick="ajax_nothrough({$voo.good_id})" type="button"><span class="am-icon-copy"></span>
                                            不予通过审核
                                            </button>
                                        {else/}
                                            <button class="am-btn am-btn-default am-btn-xs am-hide-sm-only" onclick="ajax_nothrough({$voo.good_id})" disabled type="button"><span class="am-icon-copy"></span>
                                            无法操作
                                            </button>
                                        {/if}

                                        {if ($voo.status == "已售出" || $voo.status == "卖家下架" || $voo.status == "超时下架")}
                                            <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="ajax_recycle({$voo.good_id})" disabled type="button"><span class="am-icon-trash-o"></span>
                                            无法操作
                                            </button>
                                        {elseif $voo.status == "已删除"/}
                                            <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="ajax_recycle({$voo.good_id})" type="button"><span class="am-icon-trash-o"></span>
                                            取消删除
                                            </button>
                                        {else/}
                                            <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="ajax_recycle({$voo.good_id})" type="button"><span class="am-icon-trash-o"></span>
                                            删除
                                            </button>
                                        {/if}

                                    </div>
                                </div>
                            </td>
                        </tr>
                        {/volist}
                    </tbody>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="am-panel am-panel-default">
                <div class="am-panel-hd am-cf" onclick="expand('mm')">快速处理留言<span class="am-icon-chevron-down am-fr"></span></div>
                <div class="am-panel-bd am-collapse am-in am-cf" id="childmm" style="display: none">
                    <ul class="am-comments-list admin-content-comment">

                        {volist name="top10" id="vo"}
                        <li class="am-comment">
                            <a href="#"><img src="http://s.amazeui.org/media/i/demos/bw-2014-06-19.jpg?imageView/1/w/96/h/96" alt="" class="am-comment-avatar" width="48" height="48"></a>
                            <div class="am-comment-main">
                                <header class="am-comment-hd">
                                    <div class="am-comment-meta"><a href="#" class="am-comment-author">{$vo.user_id|get_username}</a> 留言于
                                        <time>{$vo.create_time|get_time_diff=time(),###}</time>前
                                    </div>
                                </header>
                                <div class="am-comment-bd">
                                    <p>{$vo.msg}</p>

                                    <table>
                                        <tr height=22>
                                            <td><a onclick="expand({$vo.id})"
                                                    href="javascript:void(0);">回复</a></td></tr>
                                        <tr height=4>
                                            <td></td>
                                        </tr>
                                    </table>
                                    <table id="child{$vo.id}" style="display: none">
                                        <tr>
                                            <td>
                                                <textarea name="reply" cols="50" rows="5"></textarea>
                                                <p><a href="#">提交</a></p>
                                            </td>
                                        </tr>
                                    </table>

                                </div>
                            </div>
                        </li>
                        {/volist}

                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script type="text/javascript">
if (s = getCookie('index_ss')) {
    childobj = document.getElementById("childss");
    childobj.style.display = s;
}
if (s = getCookie('index_mm')) {
    childobj = document.getElementById("childmm");
    childobj.style.display = s;
}
function ajax_recycle(good_id) {
    $.get("{:url('admin/goods/recycle')}?good_id=" + good_id, function(result) {
        if (result == true) {
            alert("修改成功！");
            location.reload(true);
        }
        else
            alert("修改失败！");
    });
}
function ajax_through(good_id) {
    $.get("{:url('admin/goods/through')}?good_id=" + good_id, function(result) {
        if (result == true) {
            alert("修改成功！");
            location.reload(true);
        }
        else
            alert("修改失败！");
    });
}
function ajax_nothrough(good_id) {
    $.get("{:url('admin/goods/nothrough')}?good_id=" + good_id, function(result) {
        if (result == true) {
            alert("修改成功！");
            location.reload(true);
        }
        else
            alert("修改失败！");
    });
}
</script>
{/block}
